package com.example.teesystem.mapper;

import com.example.teesystem.entity.Class;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author 28131
* @description 针对表【t_class】的数据库操作Mapper
* @createDate 2022-03-28 11:46:43
* @Entity com.example.teesystem.entity.Class
*/
@Mapper
public interface ClassMapper extends BaseMapper<Class> {
    @Select("select course_id from t_class where is_delete = 0 and id = #{id}")
    int getCourseId(int id);

    @Select("select id from t_class WHERE class_name = #{className}")
    Integer getClassIdByName(@Param("className") String className);

    @Select("select id from t_class where course_id = #{courseId} and is_delete = 0")
    List<Integer> getClassIdsByCourse(int courseId);

    @Select("select * from t_class where id = #{id} and is_delete = 0")
    Class getClassById(int id);
    @Select("select * from t_class where is_delete = 0")
    List<Class> getClasses();

    @Select("select * from t_class where course_id = #{courseId} and is_delete = 0")
    List<Class> getClassesByCourse(int courseId);

}




